home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
CC_C
/
H515.ZIP
/
CENVID.ZIP
/
CENVI.DOC
< prev
next >
Wrap
Text File
|
1993-12-21
|
50KB
|
950 lines
CEnvi Shareware Manual, Chapter 1:
CEnvi Unregistered Shareware
CEnvi unregistered version 1.008
21 December 1993
CEnvi Shareware User's Manual
Copyright 1993, Nombas, All Rights Reserved.
Published by Nombas, P.O. Box 875, Medford, MA 02155 USA
(617)391-6595
Thank you for trying this shareware version of CEnvi from Nombas,
a member of the Association of Shareware Professionals (ASP).
1. CEnvi Unregistered Shareware
1.1. Introduction to Cmm and CEnvi
Cmm (C minus minus) is 'C' for the rest of us. CEnvi runs Cmm
programs in the DOS, Windows, OS/2, NT, Unix, etc...
environments. Together, CEnvi and Cmm make the power and
flexibility of the C programming language part of every computer
user's environment, without the hardware, time, and programmer
resources needed for developing full-blown C programs.
With CEnvi and Cmm, anyone can take control of their computer
environment. C is not just for programming nerds anymore. CEnvi
utilites, macros, batch files, and scripts can quickly be
created, shared, and modified among all computer users,
professional and amateur alike.
CEnvi can be incorporated at a pace that is comfortable to you:
you may only want to use CEnvi code set up by a more experienced
user, you may want to enhance existing batch files with a line or
two of CEnvi code, or you may write complete utilities using
CEnvi.
1.2. CEnvi unregistered shareware version
This package is the unregistered shareware version of CEnvi.
Nombas provides this unregistered shareware version of CEnvi so
that you can try the program for a while before deciding whether
to buy. If, after a few weeks of using using this product, you
think CEnvi will be useful to you and/or your organization then
use the registration form at the end of this document (or see the
file: REGISTER.DOC) to register CEnvi.
1.2.1 Why you should register
If you register, then you will receive:
*The latest version of CEnvi for all supported platforms
(currently DOS, OS/2, and Windows, with NT support expected
soon) without the annoying "Please Register" reminder.
*The CEnvi user's manual (almost 100 pages, including a
description of the Cmm programming language, a tutorial for
those who have never programmed, and descriptions and
examples of the nearly 150 functions included in the CEnvi
library).
*Free incremental electronic downloads for new versions of
CEnvi for all supported operating systems.
*Unlimited support from Nombas and CEnvi/Cmm users through
CompuServe (72212,1622), internet (bsn@world.std.com), the
cenvi-cmm e-mail mailing list (cenvi-cmm@world.std.com), and
the Nombas BBS (617-391-6595).
*Access to the growing list of CEnvi utilities and libraries
(some of which are included in this unregistered shareware
package, and others are contributed by Nombas and CEnvi/Cmm
users to the electronic locations described above).
*Discounts for additional registered version of CEnvi to use
within your organization.
1.2.2 How to register
See the REGISTER.DOC document that is included with this package
(and is also duplicated at the end of this document), to purchase
a registered version of CEnvi.
1.3. Installing CEnvi, documents, and sample files
To install this package for evaluation
* Create a directory and then copy all of these files into that
directory.
* From within that directory execute CEnvi.exe.
* At the CEnvi "Code:" prompt enter "Install.cmm" to execute
the Install program (which is written in Cmm).
* You may then test CEnvi by trying out the included example
files and by creating CEnvi code of your own.
For DOS and OS/2 versions, the install.cmm program will set up
the PATH environment variable to include the directory you
installed the files in, and will also set the CMMPATH environment
variable to this directory. For Windows, install will add the
CMMPATH profile value in WIN.INI (in the [CEnvi] section), and
will also add the CMM file extension to the [Extensions] section
in WIN.INI.
1.3.1 4DOS and 4OS2 users - .cmm executable extension
4DOS and 4OS2 users can directly execute .cmm files by
associating the .cmm file extension with your CEnvi executable.
Assuming the CEnvi.exe is in the c:\CENVID directory, then a 4DOS
user would want to add this line to AUTOEXEC.BAT:
SET .cmm=C:\CENVID\CEnvi.exe
1.4. Removing CEnvi unregistered shareware
If, after testing CEnvi for a few weeks, you choose not to
register this version of CEnvi, then you should remove the
program from your computer. (Also please consider telling Nombas
why CEnvi did not suit your needs; we need such feedback if we
are to improve the product.)
For all operating systems, the first step for removing CEnvi is
to delete all the CEnvi files and the directory that you copied
the files to. The next step depends on your operating system:
1.4.1 DOS de-installation
Install.cmm made two changes to C:\AUTOEXEC.BAT: the directory
that CEnvi was in will have been added to your PATH statement,
and the CMMPATH environment variable will have been added. To
de-install CEnvi you must remove the CEnvi directory from the
PATH statement and you must also delete the "SET CMMPATH=..."
line.
1.4.2 OS/2 de-installation
Install.cmm made two changes to C:\CONFIG.SYS: the directory that
CEnvi was in will have been added to your PATH statement, and the
CMMPATH environment variable will have been added. To de-install
CEnvi you must remove the CEnvi directory from the PATH statement
and you must also delete the "SET CMMPATH=..." line.
1.4.3 Windows de-installation
Install.cmm made two changes to WIN.INI: the CMM profile
extension was added and the CMMPATH profile string was created.
To de-install CEnvi you must edit WIN.INI (with NOTEPAD.EXE for
example) and remove from the [Extensions] section a line similar
to this:
CMM=C:\CENVI\CENVI.EXE ^.CMM
and also remove these line (or lines much like these) from
WIN.INI:
[CEnvi]
CMMPATH=E:\NOMBAS\CENVI\EXAMPLES.WIN
1.5. Using this package
1.5.1 Unregistered CEnvi shareware executable
The executable in this package, named CEnvi.EXE, is identical to
the registered version of CEnvi at the time this package was
created with one exception: this unregistered shareware version
will occasionally put up a screen to remind you to register your
copy of CEnvi (see the bottom of this document or REGISTER.DOC).
Nombas has spent, and will continue to spend, time and resources
developing and supporting CEnvi and Cmm. Without your honest
support Nombas cannot improve and support CEnvi (and pay
mortgage, feed the kids, pay the doctor, etc...).
It is likely that months have elapsed since this shareware
package has been put together (see date at the top of this file).
If so, then the version of CEnvi you receive will be an updated
version of this one. At the time of this release, incremental
improvements have been planned in memory use, speed of execution,
debugging tools, developer tools, and documentation.
1.5.2 Example programs
The following example programs are included with this shareware
version of CEnvi. Those files with a batch extension (.BAT for
DOS and .CMD for OS/2) can be run by invoking the batch file
directly. Those files with the CEnvi source file extension
(.CMM) are invoked by executing CEnvi with the file name as the
first argument (e.g. CENVI FranTick.cmm). Files with different
(e.g., *.LIB, *.H, *.DAT) are files used by CEnvi some of the
example programs.
Many of the files will provide help for how to use them if they
are invoked with "/?" as the only parameter.
All of these example files are here for you to view, study,
experiment with, and alter for your own use. The Nombas BBS will
continue to gather CEnvi and Cmm example files created by Nombas
or uploaded by CEnvi and Cmm users; so registered users will have
a large library to choose from (maybe some other CEnvi user has
already solved your need, or perhaps their need is close to yours
and you will only have to make small modifications to someone
else's uploaded CEnvi program).
1.5.3 DOS example files:
*AllDirs.bat: Perform a command in this directory and all
sub-directories
*AllFiles.bat: Perform a command on all files matching a given
file specification
*Ascii.bat: Display the ascii character table
*BatLoops.bat: Examples of various methods CEnvi can use to
allow looping within batch files
*BattMem.bat: Show values stored in a PC's battery-protected
memory
*Border.cmm: Draw a simple border on the screen
*CmmEdit.cmm: VERY simple text editor; developed step-by-step
in the tutorial chapter of the Registered CEnvi Manual.
*DelTree.bat: Delete a directory tree
*DirStat.bat: Extract specific fields from a DOS "DIR" listing
*DiskFree.bat: Display free space on a disk drive
*DosTime.bat: Show time according to computer's internal clock
*ErrLev.bat: Execute a command and set the ERRLEV value as the
return code, which makes ERRORLEVEL a variable
*Fibonacc.cmm: Two methods for generating the Fibonacci
sequence
*FileFind.bat: Wildcard search for files on current drive or on
all drives
*Find#.cmm: Extract a number from wordy output; used by
DirStat.bat
*FranTick.cmm: Animated tick who drank too much coffee
*GetUKey.cmm: Display a choice prompt and then set an
environment variable based on user's selection
*Hello.cmm: My first Cmm program. Used to begin the Cmm
tutorial.
*HexDump.bat: Display hexadecimal dump of a file
*Install.cmm: Install this registered version of CEnvi.
*IsDay_1.bat: One method to check if it is a specific day of
the week
*IsDay_2.bat: Another method to check if it's a specific day of
the week
*IsItFri.bat: Is it Friday?
*KbdBuf.bat: Alter the size of the keyboard buffer
*KbdRate.bat: Alter the typematic rate of the keyboard
*KeyCode.bat: Display keycode of any key pressed
*KeyState.bat: Get or set the state of the NumLock, CapsLock,
or Insert keys
*KeyStuff.bat: Stuff characters into the keyboard buffer
*MemBlock.bat: Trace through DOS's allocated memory blocks
*Mouse.bat: Demonstrate reading a mouse's position and state
*MultiDir.bat: DOS's "DIR" command allowing multiple file
specifications
*NumLock.bat: Set the NumLock key on
*OneADay.bat: Perform any command(s) no more than once per day
*PathAdd.bat: Add a directory to your PATH environment
variable.
*PathDel.bat: Remove a directory from your PATH environment
variable
*PathStak.bat: Multi-level save or restore of current drive and
directory so that you can change drives and directories and
still return to this one
*PathSubs.bat: Use DOS's SUBST command to shorten your PATH
environment variable so that more paths can be fit with DOS'
127-byte limit
*Primes.bat: Demonstrate automatic array allocation for
calculating prime numbers
*PrmptDay.bat: Change command-line-prompt to display today's
date
*Quote.bat: Choose a "profound" quote at random
*REBOOT_1.BAT: One method to reboot your computer
*REBOOT_2.BAT: Another method to reboot your computer
*Restrict.cmm: Allow a limited subset of DOS commands
*RunTime.bat: Rudimentary scheme for executing a command at a
certain time of day.
*SortLen.bat: Sort any file based on line length
*Sound.bat: Play a frequency for a given time period
*Tee.cmm: Save screen output to a file while it is being
displayed on the screen
*ValidDir.bat: Verify if a directory is valid
*Wait.bat: Pause and do not return for specified number of
seconds
*WinShell.bat: Start windows with a specific shell. Run
Windows for a single program.
1.5.4 OS/2 example files:
For many of these functions, you must ensure that CEnvi2PM.exe is
accessible (in the current directory or in a directory in the
search PATH). CEnvi2PM.exe is a small program used transparently
by CEnvi.exe when the PMxxxxx() calls are used to PM-specific
functions.
*AllDirs.cmd: Perform a command in this directory and all
sub-directories
*AllFiles.cmd: Perform a command on all files matching a given
file specification
*Ascii.cmd: Display the ascii character table
*BatLoops.cmd: Examples of various methods CEnvi can use to
allow looping within batch files
*BckGrnd.cmd: Specify a new file as your desktop background
image
*BigFont.cmd: Chooses the largest font for a Windowed OS/2
session. Uses KeyPush.lib.
*Border.cmm: Draw a simple border on the screen
*Bouncy.cmd: Start a bouncy OS/2 Command Window. This
demonstrates moving windows, embedding multiple Cmm
executables within one file, passing keystrokes, clipboard
use, and silliness.
*BoxFont.cmd: Show and alter default font for DOS and OS/2
command-line windows
*BoxPos.cmd: Show and alter default position for DOS and OS/2
command-line windows
*BugHunt.cmd: Example for using the ClipBrd.lib routines.
Constantly scan clipboard for "bug" in clipboard text
*CBPrint.cmd: Send contents of the clipboard to the printer
*CEnviSet.cmd: This file can be used instead of CEnvi.exe if
you are using environment variables as Cmm variables and need
them to be changed in the current OS/2 environment.
*ClipBrd.lib: Library of routines for reading from or writing
to the Windows clipboard
*CmmEdit.cmm: VERY simple text editor; developed step-by-step
in the tutorial chapter of the Registered CEnvi Manual.
*Comm.lib: Serial communications routines
*DelTree.cmd: Delete a directory tree
*Devices.cmd: Show status of system devices.
*DevIOCtl.lib: Function library for OS/2's DosDevIOCTL
functions
*DirStat.cmd: Extract specific fields from an OS/2 "DIR"
listing
*DiskFree.cmd: Display free space on a disk drive
*DoFiles.cmd: Perform any command on a list of files selected
from a file dialog box
*DosCalls.lib: Example library of "wrapper" function calls to
OS/2 API calls in the DosCalls library. This file is
"#include"ed in many of the other example files.
*DosObj.cmd: Demonstrate how to initialize any session type,
program, settings, and window positions. In this case a DOS
Window, but this is easily changed.
*DumpIni.cmd: Display profile settings from a .INI file; uses
Profile.lib
*EditCmd.cmd: Use PM's file dialog (via FileDlg.lib) to select
a *.cmd file to edit.
*EPM.cmd: Wrapper for EPM.EXE for C programmers which will
bring in related *.c, *.H and *.asm files
*ErrLev.cmd: Execute a command and set the ERRLEV value as the
return code, which makes ERRORLEVEL a variable
*Fibonacc.cmm: Two methods for generating the Fibonacci
sequence
*FileDlg.lib: A simple interface to the WinFileDlg() PM
function. This library file is #include'd in some of the
other CEnvi sample files.
*FileFind.cmd: Wildcard search for files on current drive or on
all drives
*FileIO.lib: Function to interface directly with OS/2's File IO
*Find#.cmm: Extract a number from wordy output; used by
DirStat.bat
*FranTick.cmm: Animated tick who drank too much coffee
*GetUKey.cmd: Display a choice prompt and then set an
environment variable based on user's selection
*Hello.cmm: My first Cmm program. Used to begin the Cmm
tutorial.
*HexDump.cmd: Display hexadecimal dump of a file
*IDLE.cmd: Change process priority to run a CEnvi program only
during system idle time.
*IdleProg.cmd: Execute a program in the background; i.e., run
only during system idle time.
*Install.cmm: Install this registered version of CEnvi.
*IsDay_1.cmd: One method to check if it is a specific day of
the week
*IsDay_2.cmd: Another method to check if it's a specific day of
the week
*IsItFri.cmd: Is it Friday?
*KbdRate.cmd: Alter the typematic rate of the keyboard
*KeyCode.cmd: Display keycode of any key pressed
*KeyGhost.cmd: Sample for using KeyPush.lib to determine if
CEnvi is worth the price of registration.
*KeyPush.cmd: Send keystroke commands directly to a window by
window title; a quick interface into KeyPush.lib
*KeyPush.lib: Library of routines for sending keystrokes to PM
or Windowed applications.
*KeyState.cmd: Get or set the state of the NumLock, CapsLock,
or Insert keys for current session or for the whole WPS
*Kill.cmd: Terminate a running process by Process ID, Window
title, full name, or partial name
*MsgBox.lib: A wrapper library for the PM WinMessageBox()
function. This file is #include'd in other CEnvi sample
files.
*MsgBoxes.cmd: Show various message box types using the
function in MsgBox.lib.
*MultiDir.cmd: OS/2's "DIR" command allowing multiple file
specifications
*NekoSavr.cmd: This basic screen saver program runs NEKO.EXE,
OS/2's cat & mouse game, when the mouse keys and keyboard
have been idle.
*NumLock.cmd: Turn on NUMLOCK key once, or maintain NUMLOCK ON.
A shadow of NumLock.cmd can be put in startup folder to
default computer to NumLock ON. "NumLock 1000" will check
every second to make sure that NUMLOCK is still set.
*OneADay.cmd: Perform any command(s) no more than once per day
*OS2Time.cmd: Show time according to computer's internal clock
*Parents.cmd: Show hierarchical list of ancestor's process ID's
and names
*PathAdd.cmd: Add a directory to your PATH environment
variable.
*PathDel.cmd: Remove a directory from your PATH environment
variable
*PathStak.cmd: Multi-level save or restore of current drive and
directory so that you can change drives and directories and
still return to this one
*PMdll.lib: Example library of "wrapper" routines to function
in the PM DLL (Presentatiom Manager Dynamic Link Library).
This file is "#include"ed in many of the other example files.
*Primes.cmd: Demonstrate automatic array allocation for
calculating prime numbers
*PrmptDay.cmd: Change command-line-prompt to display today's
date
*ProcList.cmd: Show list of all running processes; their names
and ID's
*Profile.lib: Function library for accessing Profiles; i.e.
.INI files
*Quote.cmd: Choose a text-mode "profound" quote at random
*QuotePM.cmd: Choose a PM-mode "profound" quote at random
*RndBckgr.cmd: Randomly select desktop background, at specified
interval, from a list of graphic file specifications
*RunTime.cmd: Rudimentary scheme for executing a command at a
certain time of day.
*Setup.cmd: Open the OS/2 Setup folder on the desktop
*ShutDown.cmd: Automated shutdown of OS/2 system
*SortLen.cmd: Sort any file based on line length
*Sound.cmd: Play a frequency for a given time period
*Switch.cmd: Switch foreground application to another process
base on process ID, full name, or partial name
*Terminal.cmd: A VERY basic terminal program; demonstrates
COMM.LIB
*Threads.cmd: Display list of all threads in all running
processes
*ValidDir.cmd: Verify if a directory is valid
*Wait.cmd: Pause and do not return for specified number of
seconds
*Windows.cmd: Start up full-screen windows session with
specified Windows program. This file contains specific DOS
notebook settings that should be altered to meet your
computer's configuration.
*WinList.cmd: Display list of all PM windows
*WinSet.cmd: Set the position, size, state, etc... of a PM
Window
*WinTools.cmd: Demonstrate many of the capabilities of
WinTools.lib
*WinTools.lib: Library of routines for manipulating PM windows
by name or by handle
*WPFolder.cmd: Open a desktop folder for any specified
directory and optionally switch to that window
1.5.5 Windows example files:
The following CEnvi source programs can be run by associating the
.cmm file extension with CEnvi.exe. This can be done by using
the File Manager: select one of these .cmm files then choose
File/Association and select the full path to CEnvi.exe. After
this, you can run any of these exmple files simply by
double-clicking on it.
*Ascii.cmm: Display the ascii character table
*BattMem.cmm: Show values stored in a PC's battery-protected
memory
*BootEd1.cmm: Start NotePad to edit c:\AutoExec.bat and
C:\Config.sys using Windows DLL's.
*BootEd2.cmm: Start NotePad to edit c:\AutoExec.bat and
C:\Config.sys using CEnvi's spawn() function.
*Border.cmm: Draw a simple border on the screen
*BugHunt.cmm: Example for using the ClipBrd.lib routines.
Constantly scan clipboard for "bug" in clipboard text
*ClipBrd.lib: Library of routines for reading from or writing
to the Windows clipboard
*CmmEdit.cmm: VERY simple text editor; developed step-by-step
in the tutorial chapter of the Registered CEnvi Manual.
*Comm.lib: Simplified function interface into Windows' serial
communication routines
*DosTime.cmm: Show time according to computer's internal clock
*Fibonacc.cmm: Two methods for generating the Fibonacci
sequence
*FranTick.cmm: Animated tick who drank too much coffee
*GDI.cmm: Demonstrate some of Windows' graphics functions from
GDI.lib
*GDI.lib: Library of a few of Windows' graphics routines
*Hello.cmm: My first Cmm program. Used to begin the Cmm
tutorial.
*HexDump.cmm: Display hexadecimal dump of a file
*Icons.cmm: Minimize all windows. Demonstrate PostMessage()
from Message.lib.
*IdleTime.cmm: "ScreenSaver" - Show clock if computer is idle
*Install.cmm: Install this registered version of CEnvi.
*KeyCode.cmm: Display keycodes returned by getch().
*KeyGhost.cmm: Demonstrate how to use KeyPush.lib to control
other applications.
*KeyPush.lib: Library of routines created for passing
keystrokes to a window with the current focus.
*Message.lib: Wrapper for Windows' PostMessage() and
SendMessage() function to send commands to windows.
*MsgBox.lib: A wrapper library for Windows' MessageBox()
function. This file is #include'd in other CEnvi sample
files.
*MsgBoxes.cmm: Show various message box types using the
function in MsgBox.lib.
*NumLock.cmm: Set the NUMLOCK key ON
*OpenCmm.cmm: Use Windows' common dialog (via PickFile.lib) to
select a *.cmm file to edit.
*PickFile.lib: A simple interface to the GetOpenFileName()
function in the Windows Common Dialog DLL. This library file
is #include'd in some of the other CEnvi sample files.
*PMCorner.cmm: Minimize Program Manager and then move its icon
to the lower-right corner of the screen.
*PongTime.cmm: Bounce the Windows clock mini-app around
*Quote.cmm: Choose a "profound" quote at random
*RunTime.cmm: Schedule a command to execute at a specified hour
and minute.
*Terminal.cmm: A simple terminal program; demonstrate some of
the functions in COMM.lib
*WhoRYou.cmm: Design and implement a dialog box using CEnvi's
MakeWindow() and DoWindows() functions
*WinBeep.cmm: Call Windows' MessageBeep() function.
*Window.lib: A few functions and many defined values useful for
CEnvi's MakeWindow(), BreakWindow(), and DoWindows()
functions
*WinExec.lib: A wrapper library for Windows' WinExec()
function. This file is #include'd in other CEnvi sample
files.
*WinExecs.cmm: Demonstration of Windows' WinExec() function
using the wrapper from WinExec.lib.
*WinList.cmm: Show a list of all Windows, their handles, and
their children.
*WinMsg.cmm: Demonstrate how to make a window, and show all the
messages that go to that window
*WinShell.bat: Start windows with a specific shell. Run
Windows for a single program. This use CENVI.EXE for DOS.
*WinTools.cmm: Demonstrate many of the capabilities of
WinTools.lib
*WinTools.lib: Library of routines for directly manipulating
windows by name or by handle
*WinUtil.lib: A small selection of utilities that may be
#include'd in CEnvi code to get simple access to Windows DLL
functions.
1.6. CEnvi - A Cmm Interpreter
This section describes the CEnvi program, and describes the
various methods for use CEnvi.exe to execute Cmm programs.
1.6.1 What is CEnvi?
CEnvi is the first (and so far only) application to implement the
Cmm programming language. CEnvi is a Command-line version of a
Cmm interpreter, and it can use Environment variables as if they
were global Cmm variables. CEnvi contains a reasonable facsimile
of the standard C library, and can link at runtime to external
Cmm libraries.
The "Envi" and the "C" in CEnvi reflects the envy that computer
professionals often feel when they are working on a computer that
does not have a complete C programming environment. "Envi" also
refers to the environment variables that CEnvi attempts to work
with as if they were regular Cmm variables.
Like all implementations for Cmm, CEnvi is portable between
operating systems. It is currently testing under DOS, OS/2, and
Windows, and other OS ports are in the works.
1.6.2 Environment Variables
Variables in all UPPERCASE letters are taken from the environment
variables. Environment variables are treated like other
variables except that they don't need quotes around them to
default to being strings if they don't match another type.
To the source code, the only difference between a variable and an
environment variable is that environment variables are all
UPPER_CASE letters. When the environment variable is first used
it is read from the environment block and some assumptions are
made about what kind of variable it is; this can lead to problems
when I=666 is interpreted as the number 666 when really it maybe
should have been the string "666". Before the program exits, all
environment variables used by the code are then written to the
environment block.
In some implementations (CEnvi for DOS, for example) the
environment variables remain changed even after the Cmm
interpreter exits. In other cases, special kludges must be added
to alter a parent process' environment variables (see ESet() for
OS/2).
1.6.3 Special Environment Variables
These environment variables affect where CEnvi looks for source
files:
*CMMPATH: This environment will be checked for directories to
search for include files if the include file is not in the
current directory. For Windows, this value may come from the
CMMPATH profile value in WIN.INI (in the [CEnvi] section).
*PATH: Batch-file source files (see below) will be searched in
these directories if not found in the current directory.
*CENVI_ESET: In those environment for which CEnvi cannot
covertly alter the environment variables of the command
interpreter (e.g., OS/2), this environment variable specifies
a file name. CEnvi will write the strings necessary for the
command interpreter to set environment variables as altered
by your Cmm code. See the description of ESet() for more
information about this command.
1.6.4 Executing Code as command-line Input Parameters
If a Cmm program is very short, then it can be executed wholly
from the command line. For example, here is the famous hello
world program executed from the cli prompt:
CEnvi main() { printf("Hello world!"); }
which can be written more conisely under Cmm rules as:
CEnvi printf("Hello world!")
You may have to keep in mind bahavior of the cli when inputting
code. It is sometimes necessary to put quotes around code to
keep symbols from being interpreted by the cli, as in this
example:
CEnvi "for(i=0;i<10;i++) printf("%d\n",i)"
where the quotes are necessary to prevent the cli from
interpreting the "<" as file redirection.
Also, in batch files (DOS, OS/2) you need to remember that "%"
has special meaning for the batch file processor, and so the
above line in a batch would have to be written as:
CEnvi "for(i=0;i<10;i++) printf("%%d\n",i)"
1.6.5 Executing *.CMM Source File Code
A file with the extension ".CMM", if the file name is given as
the first parameter to CEnvi.exe, is considered by CEnvi to be
pure CMM source code. This file with the .CMM extension is
expected to be a plain Cmm source file, just as a C compiler
expects a file with the .C extension to be C source code. CEnvi
will check the current directory for the .CMM file, and then
check directories in the PATH environment variable. Any
arguments passed to CEnvi.exe after the .CMM source name are
given to the main(argc,argv) function in the source, if there is
one. So the hellow.cmm program can look identical to the
hellow.c program, and when you run CEnvi.exe hellow.cmm you get
the same output. If you run
CEnvi.exe FOO.CMM One Two Three
the main function in FOO.CMM would get argc=4 and
argv[0]="FOO.CMM" and argv[3]="THREE".
This all means that if you were to have an executable FOO.EXE
that is similar to FOO.CMM, then "FOO.EXE" is interchangeable
with "CENVI FOO.CMM", i.e.,
FOO.EXE arg1 arg2 arg3
is the same as:
CENVI FOO.CMM arg1 arg2 arg3
In OS/2 or windows or other environments where file extensions
can be associated with programs, you may want to associate the
.CMM extension with CEnvi.exe, so that double-clicking on
HELLOW.CMM will act identically to double-clicking on the
compiled-and-linked HELLOW.EXE.
1.6.6 Batch-File Kludge
The most convenient method for executing Cmm source code from the
DOS or OS/2 command line is sort of a kludge: if the first
argument to CEnvi is the name of a batch file, then CEnvi reads
that batch file and accepts as source all the code between the
lines "GOTO CENVI_EXIT" and ":CENVI_EXIT", and passes the command
line arguments to main(argc,argv). This is very similar to
executing:
CEnvi.exe #include'foo,bat,,GOTO CENVI_EXIT,:CENVI_EXIT'
except that the '#include' statement is handled automatically by
CEnvi, and the rest of the command-line arguments are passed to
main().
Note that ".bat" is the DOS version of the batch file name
extension. This name is different for different operating
systems.
In this way, a batch file can be run exactly like a .EXE file,
and the command arguments are passed to main in the same way. If
the full path of the batch file is not supplied, then CENvi will
look in the current directory and then in directories in the
PATH.
Here is an example of an OS/2 batch file that expects any number
(up to 9) of integers and sets the SUM environment variable to
the values added together. (It calls CEnviSet instead of CEnvi
directly in order to set the environment variable.)
@echo off
REM *********************************************************
REM *** SUM.BAT - Use CEnvi to sum lots of numbers together,*
REM *** setting the SUM environment variable to *
REM *** the result of adding all the numbers. *
REM *********************************************************
call CEnviSet %0.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
GOTO CENVI_EXIT
main(argc,argv)
{
SUM = 0;
for ( i = 1; i < argc; i++ )
SUM += atoi(argv[i])
}
:CENVI_EXIT
1.6.7 EXTPROC: *.CMD Source file (For OS/2)
Under the OS/2 command processor, you can define an external
processor to process a batch (*.cmd) file if the first statement
is EXTPROC. EXTPROC is followed by the name of the processor,
which in this case will be "CEnvi". This is an example file,
ARGS.CMD, of a program to display all input parameters:
EXTPROC CEnvi
main(argc,argv)
{
for ( i = 0; i < argc; i++ )
printf("Input argument %d = \%s\n",i,argv[i]);
}
1.6.8 REXX-File Kludge (For OS/2)
Similar to the Batch-File Kludge described above, if the first
argument to CEnvi is the name of a REXX source file then CEnvi
automatically executes the code between "SIGNAL CENVI_EXIT" and
"CENVI_EXIT:". This example Rexx file for OS/2 behaves the same
as the previous batch program example (CEnviSet.cmd is an OS/2
batch file that helps run Cmm files if environment variables need
to be altered--see ESet in the OS2Lib appendix):
/***********************************************************
*** SUM.CMD - Use CEnvi to sum lots of numbers together,***
*** setting the SUM environment variable to ***
*** the result of adding all the numbers. ***
***********************************************************/
'call CEnviSet %0.cmd %1 %2 %3 %4 %5 %6 %7 %8 %9'
SIGNAL CENVI_EXIT
main(argc,argv)
{
SUM = 0;
for ( i = 1; i < argc; i++ )
SUM += atoi(argv[i])
}
CENVI_EXIT:
1.6.9 CMM File Association and Drag-and-Drop (OS/2)
You can associate CEnvi.exe with .cmm files through the settings
notebook of CEnvi.exe. This lets you executed any CEnvi *.cmm
file simply by double-clicking its icon in the desktop.
A Cmm program can be set up as a Workplace Shell program that
accepts drag and drop. To do this, drag a program template out
of the templates folder and place it on the desktop where you
want your Cmm program to run from. In program settings for this
program object set the program name to the path and file
specification for CEnvi.exe (e.g., "C:\CMM\CEnvi.exe"). Set
Parameters to the full source and file name of the Cmm file
(e.g., "C:\CMM\CZIP.cmm"). Then rename the program object to
whatever you want (e.g., "CZIP"). Then whenever you drag a file
onto that object then the filename will be the second argument to
main().
1.6.10 CMM File Association and Drag-and-Drop (Windows)
You can associate Cmm files with CEnvi.exe by using the File
Manager: select a .cmm file then choose File/Association and
select the full path to CEnvi.exe. After this, you can run any
of *.cmm program simply by double-clicking on it.
1.6.11 /BIND= Create Stand-Alone Cmm Executables
The CEnvi /BIND option allows you to create stand-alone,
royalty-free executables from your Cmm code. The result of /BIND
is a binary executable file that operates the same as if CEnvi
were invoked as an interpreter, except that CEnvi.exe is not
needed to execute the bound file, because CEnvi.exe and your Cmm
code are bound together in the created executable.
The following example creates an executable named HELLOW.EXE that
would print "Hello world!".
CEnvi /BIND=HELLOW printf("Hello world!");
As another example, you could create a stand-alone editor, which
we'll call CMMEDIT.EXE, from the result of the CEnvi tutorial
with the following command:
CEnvi /BIND=CMMEDIT.EXE CMMEDIT.CMM
Now running "CMMEDIT.EXE C:\AUTOEXEC.BAT" from the command line
would be identical to executing "CENVI.EXE CMMEDIT.CMM
C:\AUTOEXEC.BAT".
1.6.12 /BIND for OS/2 and CEnvi2PM.EXE
When you /BIND Cmm source code that contains calls to
PMDynamicLink(), or other PMxxx() calls that invoke CEnvi2PM.exe,
the resulting executable will still require CEnvi2PM.exe. So
users running the bound executable will still need CEnvi2PM.exe
in a directory of their search path. CEnvi2PM.exe may be
distributed royalty-free.
1.6.13 /BIND for Windows
The simplest method for using /BIND in Windows is to execute
CEnvi.exe, and then to enter the /BIND statement and Cmm source
name from the CEnvi command prompt. For example, to turn
WhoRYou.cmm into the stand-alone WhoRYou.exe, you would execute
CEnvi.exe and then enter the following at the CEnvi "Code:"
prompt:
Code: /BIND=WhoRYou WhoRYou.cmm
-------------------------------- FILE LIST --------------------------------
The CEnvi Unregistered Shareware package includes the files in the
following list. You are not permitted to upload or otherwise transfer
copies of any registered version of CEnvi that does not include all of the
files in this list.
*CENVI.EXE: CEnvi shareware executable for DOS, OS/2, or Windows.
*CENVI2PM.EXE: Gateway program, executed trasnparently by CEnvi, for access
to PM-dependent system calls (OS/2 version only).
*CENVI.DOC: CEnvi Shareware Manual, Chapter 1: CEnvi Unregistered Shareware
*CMMTUTOR.DOC: CEnvi Shareware Manual, Chapter 2: Cmm Language Tutorial
*CMM_VS_C.DOC: CEnvi Shareware Manual, Chapter 3: Cmm versus C, for C
Programmers
*CENVILIB.DOC: CEnvi Shareware Manual, Chapter 4: Function Library
*LICENSE.DOC: CEnvi Unregistered Shareware License Agreement
*README.DOC: Introductory file. Read this first for quick intallation.
*REGISTER.DOC: CEnvi registration form
*INSTALL.CMM: Cmm source file for installing this shareware version
* *.CMM, *.CMD, *.BAT, *.LIB: Many many sample programs using CEnvi. See
CENVI.DOC for a complete list.
----------------------------- REGISTRATION -------------------------------
This is a shareware release. Please register. As a registered CEnvi user
you will receive:
*The latest version of CEnvi for all supported platforms (currently DOS,
OS/2, and Windows).
*The CEnvi user's manual (almost 100 pages, including a description of the
Cmm programming language, a tutorial for those who have never programmed,
and descriptions and examples of the over 150 functions included in the
CEnvi library).
*Free incremental electronic downloads for new versions of CEnvi for all
supported operating systems.
*Unlimited support from Nombas and CEnvi/Cmm users through CompuServe
(72212,1622), internet (bsn@world.std.com), the cenvi-cmm e-mail mailing
list (cenvi-cmm@world.std.com), and the Nombas BBS
(ATDT16173916595,,,,,44444).
*Access to the growing list of CEnvi utilities and libraries (some of which
are included in this unregistered shareware package, and others are
contributed by Nombas and CEnvi/Cmm users to the electronic locations
described above).
There are three ways to register CEnvi version 1.008:
***************************************************************************
********* REGISTRATION METHOD 1: CENVI MAIL-IN REGISTRATION FORM **********
***************************************************************************
Please fill out and mail in this form, along with payment.
Where did you get CEnvi? ______________________________________________
Name: _________________________________________________________________
Company: ______________________________ Position: _____________________
Address: ______________________________________________________________
_______________________________________________________________________
______________________________________________________________________
Country: _________________________ (add ZIP code if applicable)
Phone: ___________________________ EMail: ______________________________
Diskette size: [ ] 3.5" [ ] 5.25"
CEnvi Registered License & Manual.... Quantity _____ x $38.00 = $ _________
License fee for additional CEnvi users at
your organization (does not include additional
manual or diskettes)...Simultaneous-User Count _____ x $15.00 = $ _________
Additional CEnvi Manuals..............Quantity _____ x $10.00 = $ _________
Shipping outside USA, Canada, or Mexico $4.00 ................ $ _________
Subtotal $ _________
Massachusetts residents please add 5% sales tax ............... $ _________
Total $ _________
Include a check or money order for this total, IN U.S. FUNDS AND DRAWN ON A
U.S. BANK, payable to Nombas, or supply the following credit card payment
information. Credit cards orders will be processed through a distributor:
Custom Computer Systems of Medford, MA.
Credit card orders (circle one): MasterCard / Visa / American Express
Discover / Carte Blanche / Diners Club
Card Number _____________________________________ Expires ____________
Exact name on card (print) ____________________________________________
Signature (REQUIRED) __________________________________________________
Mail this form, along with payment or credit information, to:
Nombas
P.O. Box 875
Medford, MA 02155 USA
***************************************************************************
******** REGISTRATION METHOD 2: COMPUSERVE ELECTRONIC REGISTRATION ********
***************************************************************************
CompuServe members may register directly through the CompuServe
Registration Service. To use this service enter GO SWREG at your CI$
prompt. Registration ID is 1354 for CEnvi for DOS, 1355 for CEnvi for
OS/2, and 1356 for CEnvi for Windows (you only need to register ONE
version). Nombas will immediately be informed of your registration, and
the CEnvi registration fee will automatically be added to your CompuServe
bill.
***************************************************************************
************ REGISTRATION METHOD 3: Public (software) Library *************
***************************************************************************
CREDIT CARD ORDERS ONLY -
You can order with MC, Visa, Amex, or Discover from Public (software)
Library by calling 800-2424-PsL or 713-524-6394 or by FAX to 713-524-6398
or by CIS Email to 71355,470. You can also mail credit card orders to PsL
at P.O.Box 35705, Houston, TX 77235-5705.
THE ABOVE NUMBERS ARE FOR ORDERS ONLY.
Any questions about the status of the shipment of the order, refunds,
registration options, product details, technical support, volume discounts,
dealer pricing, site licenses, etc, must be directed to Nombas (see phone
number and addresses below).
To insure that you get the latest version, PsL will notify Nombas the day
of your order and we will ship the product directly to you.
CEnvi (all versions) is PsL product #11069. Prices (including shipping and
handling) are: $42 US/Canada and $45 overseas.
***************************************************************************
Thank you for trying this shareware copy of CEnvi. Mail inquires and other
correspondences to:
Nombas
P.O. Box 875
Medford, MA 02155 USA
Nombas may also be contacted at:
Phone: (617)391-6595
Internet: bsn@world.std.com
CompuServe: 72212,1622
BBS: (617)391-6595 ext. 44 (e.g., ATDT16173916595,,,,,44444)